package i2.application.fmw.exceptions;


import java.util.ArrayList;
import java.util.List;

public class ValidationException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	
	private List<ValidationMessage> validationMessages;
	
	public ValidationException() {
		super();
		validationMessages = new ArrayList<ValidationMessage>();
	}
	
	public ValidationException(String key, String message){
		super(message);
		validationMessages = new ArrayList<ValidationMessage>();
		validationMessages.add(new ValidationMessage(key, message));
	}

//	public ValidationException(ConstraintViolation<?> cons) {
//		super(cons.getMessage());
//		String key = cons.getRootBeanClass().getSimpleName().toLowerCase()+"."+cons.getPropertyPath().toString();
//		validationMessages = new ArrayList<ValidationMessage>();
//		validationMessages.add(new ValidationMessage(key, cons.getMessage()));
//	}
	
	public void add(ValidationMessage validationMessage) {
		validationMessages.add(validationMessage);
	}

	public List<ValidationMessage> getValidationMessages() {
		return validationMessages;
	}

}
